﻿@model ForumTopicPageModel
@using Nop.Web.Extensions;
@using Nop.Web.Models.Boards;
@using Nop.Web.Models.Common;
@using Nop.Core
@using Nop.Core.Domain.Seo;
@using Nop.Core.Infrastructure;
@using Nop.Services.Localization
@{
    Layout = "~/Views/Shared/_ColumnsOne.cshtml";
    Html.AddTitleParts(Model.Subject);
    Html.AddMetaDescriptionParts(Html.Encode(Model.WatchTopicText));
    Html.AddMetaKeywordParts("פורומים קניה ומכירה, ציוד יד שניה, ציוד למכירה, ציוד לקניה");

    var seoSettings = EngineContext.Current.Resolve<SeoSettings>();
    //open graph META tags
    if (seoSettings.OpenGraphMetaTags)
    {
        var storeName = EngineContext.Current.Resolve<IStoreContext>().CurrentStore.GetLocalized(x => x.Name);
        Html.AddHeadCustomParts("<meta property=\"og:title\" content=\"" + Html.Encode(Model.Subject) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:description\" content=\"Windalert\" />");
        Html.AddHeadCustomParts("<meta property=\"og:image\" content=\"http://www.windalert.co.il/themes/windalert/content/images/logo-square.jpg\" />");
        Html.AddHeadCustomParts("<meta property=\"og:image:type\" content=\"image/jpeg\" />");
        Html.AddHeadCustomParts("<meta property=\"og:image:width\" content=\"200\" />");
        Html.AddHeadCustomParts("<meta property=\"og:image:height\" content=\"200\" />");
        Html.AddHeadCustomParts("<meta property=\"og:url\" content=\"" + Request.Url.AbsoluteUri + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:site_name\" content=\"" + Html.Encode(storeName) + "\" />");
    }
    //Twitter META tags
    if (seoSettings.TwitterMetaTags)
    {
        var storeName = EngineContext.Current.Resolve<IStoreContext>().CurrentStore.GetLocalized(x => x.Name);
        Html.AddHeadCustomParts("<meta property=\"twitter:card\" content=\"summary\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:site\" content=\"" + Html.Encode(storeName) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:title\" content=\"" + Html.Encode(Model.Subject) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:description\" content=\"Windalert\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:image\" content=\"http://www.windalert.co.il/themes/windalert/content/images/logo-square.jpg\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:url\" content=\"" + Request.Url.AbsoluteUri + "\" />");
    }

}

<script type="text/javascript">
    function handleTopicWatch(context) {
        $('#watch-topic-top').text(context.Text);
        $('#watch-topic-bottom').text(context.Text);
    }
</script>
<div class="container">
    <div class="row">
        <div class="col-md-9">
            @Html.Action("ForumBreadcrumb", new { forumTopicId = Model.Id })
        </div>

        <div class="col-md-3">
            @Html.Partial("_SearchBox")
        </div>
    </div>
</div>
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default form-panel">
                <div class="panel-heading">
                            <h3>
                                @Model.Subject
                            </h3>
                </div>
                <div class="panel-body">
                    <div class="row">
                        <div class="col-lg-3 text-left">
                            <div>
                                <!-- AddThis Button BEGIN --><div class="addthis_toolbox addthis_default_style ">
                                    <a class="addthis_button_preferred_1"></a>
                                    <a class="addthis_button_preferred_2"></a>
                                    <a class="addthis_button_preferred_3">
                                    </a><a class="addthis_button_preferred_4"></a>
                                    <a class="addthis_button_compact"></a>
                                    <a class="addthis_counter addthis_bubble_style"></a>
                                </div>
                                <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=nopsolutions"></script><!-- AddThis Button END -->
                            </div>
                        </div>
                        <div class="col-md-9 text-right">

                            @if (Model.IsCustomerAllowedToEditTopic)
                            {
                                <a class="btn btn-default btn-sm" href="@Url.RouteUrl("TopicEdit", new { id = Model.Id })"><i class="fa fa-edit"></i>&nbsp; @T("Forum.EditTopic")</a>
                            }
                            @if (Model.IsCustomerAllowedToDeleteTopic)
                            {
                                <a class="btn btn-default btn-sm" href="@Url.RouteUrl("TopicDelete", new { id = Model.Id })" onclick="@(String.Format(" return confirm('{0}');", T("common.areyousure").Text))">
                                    <i class="fa fa fa-trash-o"></i>&nbsp; @T("Forum.DeleteTopic")
                                </a>
                            }
                            @if (Model.IsCustomerAllowedToMoveTopic)
                            {
                                <a class="btn btn-default btn-sm" href="@Url.RouteUrl("TopicMove", new { id = Model.Id })"><i class="fa fa-mail-forward"></i>&nbsp; @T("Forum.MoveTopic")</a>
                            }
                            <a class="btn btn-default btn-sm" href="@Url.RouteUrl("PostCreate", new { id = Model.Id })"><i class="fa fa fa-reply"></i>&nbsp; @T("Forum.Reply")</a>
                            @if (Model.IsCustomerAllowedToSubscribe)
                            {
                                <a class="btn btn-default btn-sm" href="#" id="watch-topic-top"><i class="fa fa-eye"></i>&nbsp; @Model.WatchTopicText</a>
                                <script type="text/javascript">
                                    $(function () {
                                        $('#watch-topic-top').click(function () {
                                            $.ajax({
                                                cache: false,
                                                type: 'POST',
                                                url: '@Url.RouteUrl("TopicWatch", new { id = Model.Id })',
                                                dataType: 'json',
                                                success: function (data) {
                                                    $('#watch-topic-top').text(data.Text);
                                                },
                                                error: function (xhr, ajaxOptions, thrownError) {
                                                    alert('Failed to watch');
                                                }
                                            });
                                        });
                                    });
                                </script>
                            }
                        </div>
                    </div>
                    <div>
                        @{
                            var pager = Html.Pager(new PagerModel
                                                       {
                                                           PageSize = Model.PostsPageSize,
                                                           TotalRecords = Model.PostsTotalRecords,
                                                           PageIndex = Model.PostsPageIndex,
                                                           ShowTotalSummary = false,
                                                           RouteActionName = "TopicSlugPaged",
                                                           UseRouteLinks = true,
                                                           RouteValues = new RouteValues { id = Model.Id, slug = Model.SeName }
                                                       });
                        }
                        <div class="pager">
                            @pager
                        </div>
                    </div>

                    <div class="posts">
                        @foreach (var post in @Model.ForumPostModels)
                        {
                            Html.RenderPartial("_ForumPost", post);
                            <hr />

                        }
                    </div>
                    <div @*class="container"*@>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="topic-footer">
                                    <div class="topic-options text-right">
                                        <a class="btn btn-default btn-sm" href="@Url.RouteUrl("PostCreate", new { id = Model.Id })"><i class="fa fa fa-reply"></i>&nbsp; @T("Forum.Reply")</a>
                                    </div>
                                    <div class="pager">
                                        @pager
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


